﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VideoBlog.Data.Entities;

namespace VideoBlog.Web.Models
{
    public class PlaylistViewModel
    {
        public string Title { get; private set; }
        public List<Video> Videos { get; set; }
        public Video NowPlaying { get; private set; }
        public Category Category { get; private set; }
        public string Image { get; set; }

        public PlaylistViewModel() { }
        public PlaylistViewModel(string title) { Title = title; }
        public PlaylistViewModel(string title, List<Video> videos, Video nowPlaying) 
        { 
            Title = title; 
            Videos = videos;
            NowPlaying = nowPlaying ?? videos.First();
            if (!NowPlaying.Playlist.CategoryReference.IsLoaded)
                NowPlaying.Playlist.CategoryReference.Load();

            VideoBlogEntities2 db = new VideoBlogEntities2();
            Category = db.Category.Where(o => o.CategoryID == NowPlaying.Playlist.Category.CategoryID).First();
        }
    }
}
